package com.qiangesoft.bootcodegen.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qiangesoft.bootcodegen.entity.BcgTableColumn;
import com.qiangesoft.bootcodegen.framework.log.Log;
import com.qiangesoft.bootcodegen.service.IBcgTableColumnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 表字段配置 前端控制器
 * </p>
 *
 * @author qiangesoft
 * @date 2024-03-28
 */
@Api(tags = "表字段配置")
@RequiredArgsConstructor
@RestController
@RequestMapping("/tableColumn")
public class BcgTableColumnController {

    private final IBcgTableColumnService tableColumnService;

    @Log(module = "表字段配置", operationName = "查询字段配置")
    @ApiOperation(value = "查询字段配置")
    @GetMapping("/{tableId}")
    public List<BcgTableColumn> listTableColumn(@PathVariable Long tableId) {
        LambdaQueryWrapper<BcgTableColumn> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BcgTableColumn::getTableId, tableId).orderByAsc(BcgTableColumn::getSort);
        return tableColumnService.list(queryWrapper);
    }
}
